<template>
  <div class="app">
    <header class="app-header">
      <div class="header-content">
        <div class="logo">
          <span class="logo-icon">📹</span>
          <h1>医疗图像分析系统</h1>
        </div>
        <div class="header-actions">
          <span class="system-time">{{ currentTime }}</span>
        </div>
      </div>
    </header>
    
    <main class="app-main">
      <CameraPreview />
      
      <div class="info-panel">
        <div class="panel-header">
          <h2>系统信息</h2>
        </div>
        <div class="panel-content">
          <div class="info-item">
            <span class="info-label">服务器状态:</span>
            <span class="info-value success">正常</span>
          </div>
          <div class="info-item">
            <span class="info-label">模型版本:</span>
            <span class="info-value">v1.0.0</span>
          </div>
          <div class="info-item">
            <span class="info-label">客户端版本:</span>
            <span class="info-value">v1.0.0</span>
          </div>
        </div>
      </div>
    </main>
    
    <footer class="app-footer">
      <p>© 2025 医疗图像分析系统 | 技术支持</p>
    </footer>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted, onBeforeUnmount } from 'vue';
import CameraPreview from './views/CameraPreview.vue';

// 当前时间
const currentTime = ref('');
let timer: number | null = null;

// 更新时间
const updateTime = () => {
  const now = new Date();
  const hours = now.getHours().toString().padStart(2, '0');
  const minutes = now.getMinutes().toString().padStart(2, '0');
  const seconds = now.getSeconds().toString().padStart(2, '0');
  currentTime.value = `${hours}:${minutes}:${seconds}`;
};

onMounted(() => {
  updateTime();
  // 每秒更新一次时间
  timer = window.setInterval(updateTime, 1000);
});

onBeforeUnmount(() => {
  if (timer !== null) {
    clearInterval(timer);
  }
});
</script>

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Microsoft YaHei', Arial, sans-serif;
  background-color: #f5f8fa;
  color: #333;
  min-height: 100vh;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  background-color: #2c3e50;
  color: white;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  padding: 15px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 1.8rem;
}

.logo h1 {
  font-size: 1.5rem;
  margin: 0;
  color: white;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

.system-time {
  font-size: 0.95rem;
  background-color: rgba(255, 255, 255, 0.1);
  padding: 5px 10px;
  border-radius: 4px;
}

.app-main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
}

.info-panel {
  margin-top: 20px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.panel-header {
  background-color: #f1f5f9;
  padding: 15px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.panel-header h2 {
  font-size: 1.1rem;
  color: #2c3e50;
  margin: 0;
}

.panel-content {
  padding: 15px 20px;
}

.info-item {
  display: flex;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.info-item:last-child {
  border-bottom: none;
}

.info-label {
  flex: 0 0 120px;
  color: #6c757d;
  font-weight: 500;
}

.info-value {
  color: #333;
}

.info-value.success {
  color: #28a745;
}

.app-footer {
  background-color: #2c3e50;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  padding: 15px;
  margin-top: 30px;
  font-size: 0.9rem;
}

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 10px;
  }
  
  .logo {
    margin-bottom: 5px;
  }
}
</style>
